<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>固定定位</title>
    <style>
        body {
            height: 2000px;
        }

        .box {
            width: 200px;
            height: 200px;
            background: #000;
        }

        .title {
            background: aquamarine;
            position: sticky;
            top: 0;
        }
    </style>
</head>

<body>
    <div class="box"></div>
    <div class="title">导航栏</div>
</body>

</html>